#include <stdio.h>

int main(void)
{
    int days, starting, i;

    printf("Enter number of days in month: ");
    scanf("%d", &days);

    printf("Enter starting day of the week (1=Sun, 7=Sat): ");
    scanf("%d", &starting);

    printf("\tSun\tMon\tTue\tWes\tThu\tFri\tSat\n");

    for (i = 1; i < days + starting;)
    {
        while (i < starting)
        {
            printf("\t");
            i++;
        }

        printf("\t%d", i - starting + 1);
        if (i % 7 == 0)
            printf("\n");
        i++;
    }

    return 0;
}